	<?php $this->load->view('common/head')?>
	
	<!-- Begin of Sidebar -->
	<?php $this->load->view('common/sidebar')?>
	
	<?php /*********************************/ ?>
	
	
	
	
	<?php /****************************/ ?>
	<script type="text/javascript">
		
								
		/** A-Z List**/
		function a_z_list()
		{
			$('#slider_2').html('');
			yi = 0;
			slider_2 = "";
			ar_array2 = new Array();
			//group by 
			$.post("<?php echo site_url('previous_event/get_info/')?>/",
				function(data){
				slider_2+= '<div class="slider-content"><ul>';
					$.each(data,function(xix,ee) {
					yi++;
					//xix = the character //yy = the objects
					//put character this array to pass the items option
					ar_array2[yi] = xix;
					//character title (above the names)
					slider_2+='<li id="'+xix+'"><a name="'+xix+'" class="title">'+xix+'</a><ul>';
						
						for(var i=0; i < ee.length; i++){
							slider_2+='<li><a href="javascript:void('+ee[i].id+');" onClick="load_info('+ee[i].id+')">'+ee[i].name+'</a></li>';
						}//end for
					slider_2+='	</ul></li>';
					})//end .each
					slider_2+='</div>';
					$('#slider_2').append(slider_2).sliderNav({items:ar_array2});
			}, 'json');
		$('.a-z-list').parent().children('.block-content').slideToggle();
		}
		/** END A-Z List **/
		
		/** load_form **/
		function load_form(id)
		{
			
			$('.load_option').slideUp('slow');
			$('#for_title').html('<center><img src="<?php echo $this->config->item('images')?>/loading2.gif" alt="Loading..." title="Loading..." /> Loading... </center>');
			if(id==null)
			{
				//load empty form
				$('.load_option').load('previous_event/form', function() {
				  $('#for_title').html('Add New Event');
				  $('.load_option').slideDown('slow');
				});
			}
			else{
				//load form
				$('.load_option').load('previous_event/form/'+id, function() {
				  $('#for_title').html('Edit Event');
				  $('.load_option').slideDown('slow');
				});
			}
		}
		/** END load_form **/
		
		/** function Delete **/
		function del(com)
		{
			//$( "#dialog-confirm" ).dialog(open);
			$( "#dialog-confirm" ).dialog({
				resizable: false,
				height:150,
				modal: true,
				buttons: {
					"Are You Sure ? (Yes Delete!)": function() {
							$('#for_title').html('<center><img src="<?php echo $this->config->item('images')?>/loading2.gif" alt="Loading..." title="Loading..." /> Loading... </center>');
							$.post("<?php echo site_url('previous_event/delete/')?>/"+com,
								function(data){
									//alert(data)
									if(!data.error){
										$.jGrowl( data.msg, { theme: 'saved',position:'center'  });
										$('.a-z-list').parent().children('.block-content').slideToggle();
										a_z_list();
										$('#for_title').html('Options & Settings for (Contacts)');
										$('.load_option').slideUp('slow');
									}
									else{
										$.jGrowl('Error: '+data.msg, { theme: 'error',position:'center'  });
									}
							},'json');
							$( this ).dialog( "close" );
					},
					Cancel: function() {
						$( this ).dialog( "close" );
					}
				}
			});
			
		}
		/** End function Delete **/
							
		/*** function load info **/
		function load_info(com)
		{

			//Reset all 
			$('.load_option').slideUp('slow');
			$('#for_title').html('<center><img src="<?php echo $this->config->item('images')?>/loading2.gif" alt="Loading..." title="Loading..." /> Loading... </center>');

			info = '';
								
			$.post("<?php echo site_url('previous_event/get_info/')?>/"+com,
				function(data){					
						
					info+='<div class="alert note"><strong>Actions</strong> for : '+data.event_name +' - '+data.event_subject+'</div>';
					info+='<div class="block-content">'
					info+='<ul class="block-list with-icon">'
					info+='<li class="i-16-drive"><a href="javascript:;">Show All Related Contacts for this Event</a></li>'
					info+='<li class="i-16-calendar"><a href="javascript:;" onClick="load_form('+com+')">Edit</a></li>'
					info+='<li class="i-16-cross"><a href="javascript:;" onClick="del('+com+')">Delete</a></li>'
					info+='<li class="i-16-briefcase">Organisers: <b>'+data.com +'</b></li>'
					info+='<li class="i-16-toilet">Responsable: <b>'+data.name_ar +' - '+data.name_en+'</b></li>'
					info+='<li class="i-16-star">Event Started on: <b>'+data.event_start +'</b></li>'
					info+='<li class="i-16-star-empty">Event Ended on: <b>'+data.event_end +'</b></li>'
					info+='<li class="i-16-shopping-basket">Seasonal: <b>'+data.seasonal +'</b></li>'
					info+='<li class="i-16-map">Address: <img src="<?php echo $this->config->item('images')?>/flags/'+data.country+'.gif" alt="'+data.country+'" title="'+data.country+'" /> <b>'+data.country +' - '+data.city +'</b> - '+data.address+'</li>'
					info+='<li class="i-16-notebook">Notes: <b>'+data.notes +'</b></li>'
					info+='<li class="i-16-eye">Attendance: <b>'+data.attendance +'</b></li>'
 
					info+='</ul>'
					info+='</div>'
					
					info+='<div><br></div>';
					
					$('.load_option').html(info);
					$('.load_option').slideDown('slow');
					$('#for_title').html(data.event_name+' - '+ data.event_subject);

			}, 'json');
		}
		
		/*** END load info **/	
		
		
	$().ready(function() {
		
		
		
		$('#dialog').dialog({ 
				minWidth: 450,
				position: "top",
				autoOpen: false,
				modal: true, 
				show: "slide", 
				hide: "slide",
				title: "Loading Event Info..." 
		});
		
		
		});
		
		a_z_list();
    </script>
    
	<?php /****************************/ ?>
	
	
	<!-- Modal Box Content -->
	<div id="dialog" title="About" style="display: none;">
		<p class='p1'></p>
		<p class='p2'></p>
	</div> 
	<!--! end of #info-dialog -->
	
	<div id="dialog-confirm" title="Delete?" style="display: none;">
	<p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span>This Event will be permanently deleted and cannot be recovered. Are you sure?</p>
	</div>
	
	
    <!-- Begin of #main -->
    <div id="main" role="main">
    	
    	<!-- Begin of titlebar/breadcrumbs -->
		<div id="title-bar">
			<ul id="breadcrumbs">
				<li><a href="<?php echo site_url()?>" title="Home"><span id="bc-home"></span></a></li>
				<li><a href="<?php echo site_url('previous_event')?>" title="Previous Event">Previous Event</a></li>
				<li class="no-hover">Main</li>
			</ul>
		</div> <!--! end of #title-bar -->
		
		<div class="shadow-bottom shadow-titlebar"></div>
		
		<!-- Begin of #main-content -->
		<div id="main-content">
			<div class="container_12">
			
			<!-- Put your content here! -->
			<div class="grid_12">
				<div class="block-border">
				<div class="block-header"><h1>Previous Event</h1></div>
				<div class="block-content">
						<div class="block-actions">
							<ul class="actions-right">
								<li><button class="submit" onClick="load_form()">Add New Event</button></li>
								<li><button class="submit">Filter Events</button></li>
							</ul>
						</div>
					</div>
					</div>
			</div>
				
			<!--  -->
		<div class="grid_6">
				<div class="block-border">
					<div class="block-header">
						<h1 id="for_title">Options & Settings for (Events)</h1><span></span>
					</div>
					<div class="block-content ">
						<div class="load_option"></div>
					</div>

				</div>
			</div>
			
			<!--  -->
			<div class="grid_6">
				<div class="block-border">
					<div class="block-header">
						<h1>A-Z List</h1><span></span>
					</div>
					
					<div class="block-content a-z-list">
						<div id="slider_2">
						</div>
					</div>
				</div>
			</div>
			
		
			
			<div class="clear height-fix"></div>

		</div></div> <!--! end of #main-content -->
  </div> <!--! end of #main -->	







	<?php /*********************************/ ?>
	<!-- Begin of footer -->
	<?php $this->load->view('common/footer')?>
